package org.ilc.message;

import org.ilc.push.ISendTask;
import org.ilc.push.Message;

import java.util.concurrent.ThreadPoolExecutor;

class QueueExecutor {
	private ThreadPoolExecutor threadPool = null;
	public QueueExecutor(ThreadPoolExecutor threadPool){
		this.threadPool=threadPool;
	}
	
	public void execute(Message message, ISendTask sendTask){
		threadPool.execute(new Sender(message, sendTask));
	}
	class Sender implements Runnable{
		private Message message;
        private ISendTask sendTask;

		public Sender(Message message, ISendTask sendTask){
			this.message=message;
            this.sendTask = sendTask;
		}
		@Override
		public void run() {
			sendTask.send(message);
			
		}
		
	}
}
